package com.hex.liyue.usermodule.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hex.liyue.R;
import com.hex.liyue.commonmodule.activity.BaseActivity;
import com.hex.liyue.commonmodule.utils.StatusBarCompatUtils;
import com.hex.liyue.usermodule.presenter.IUpdataPwdView;
import com.hex.liyue.usermodule.presenter.UpdataPwdPresenter;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 这是一个修改密码的方法
 * Created by yukoyuan on 16/6/17.
 */
public class UpdatePwdActivity extends BaseActivity implements IUpdataPwdView {
    @Bind(R.id.iv_toobar_back)
    ImageView ivToobarBack;
    @Bind(R.id.tv_toobar_title)
    TextView tvToobarTitle;
    @Bind(R.id.et_resetpwd_oldpwd)
    EditText etResetpwdOldpwd;
    @Bind(R.id.et_resetpwd_newpwd)
    EditText etResetpwdNewpwd;
    @Bind(R.id.et_resetpwd_cofirm_newpwd)
    EditText etResetpwdCofirmNewpwd;
    private UpdataPwdPresenter updataPwdPresenter;
    @Override
    protected void bindPresenter() {
        updataPwdPresenter = new UpdataPwdPresenter(this);
    }

    @Override
    protected void initData(Bundle extras) {

    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_updatapwd;
    }

    @Override
    protected void initToolbar() {
        StatusBarCompatUtils.compat(this);
        ivToobarBack.setVisibility(View.VISIBLE);
        tvToobarTitle.setVisibility(View.VISIBLE);
        tvToobarTitle.setText("修改密码");
    }


    @OnClick({R.id.iv_toobar_back, R.id.bt_reset_pwd})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_toobar_back:
                onBackPressed();
                break;
            case R.id.bt_reset_pwd:
                updataPwdPresenter.UpdataPwd();
                break;
        }
    }

    @Override
    public String getOldPwd() {
        return etResetpwdOldpwd.getText().toString().trim();
    }

    @Override
    public String geTNewPwd() {
        return etResetpwdNewpwd.getText().toString().trim();
    }

    @Override
    public String getSecondPwd() {
        return etResetpwdCofirmNewpwd.getText().toString().trim();
    }

    @Override
    public void startLoginAndRegistActivity() {
        appStackUtil.finishAllActivity();
        Intent intent = new Intent(this, LoginAndRegistActivity.class);
        startActivity(intent);
    }

    @Override
    public void showLod(String msg) {
        showLoad(this, msg);
    }

    @Override
    public void closeLod() {
        closeLoad();
    }

    @Override
    public void showT(String msg) {
        showToast(this, msg);
    }
}
